package com.siam.package_rider.controller.rider;

import com.siam.package_common.entity.BasicResult;
import com.siam.package_rider.model.param.RiderWithdrawParam;
import com.siam.package_rider.model.param.TbRiderParam;
import com.siam.package_rider.model.result.TbRiderResult;
import com.siam.package_rider.service.TbRiderService;
import com.siam.package_user.model.param.MemberWithdrawRecordParam;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * ---------------------------
 * 骑手表 (TbRiderController)         
 * ---------------------------
 * 作者：  高品
 * 时间：  2025-03-29 18:55:18
 * ---------------------------
 */
@RestController
@RequestMapping("/rest/rider")
public class TbRiderController {

	@Autowired
	private TbRiderService riderService;


	/**
	 * 注册
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/register")
	public BasicResult register(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.register(param);
		return BasicResult.success();
	}

	/**
	 * 设置骑手账户信息（注册流程的第二步，提交后会自动登录）
	 *
	 * @author 高品
	 */

	@PostMapping(value = "/fillAccountInfo")
	public BasicResult fillAccountInfo(@RequestBody @Validated(value = {}) TbRiderParam param) {
		TbRiderResult result = riderService.fillAccountInfo(param);
		return BasicResult.success(result);
	}

	/**
	 * 提交接单资格相关信息
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/fillVerificationInfo")
	public BasicResult fillVerificationInfo(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.fillVerificationInfo(param);
		return BasicResult.success();
	}

	/**
	 * 注册（包含填写接单资格信息）
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/registerWithFillVerificationInfo")
	public BasicResult registerWithFillVerificationInfo(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.registerWithFillVerificationInfo(param);
		return BasicResult.success();
	}

	/**
	 * 登录-账号密码
	 *
	 * @author 高品
	 */

	@PostMapping(value = "/login")
	public BasicResult login(@RequestBody @Validated(value = {}) TbRiderParam param) {
		TbRiderResult result = riderService.login(param);
		return BasicResult.success(result);
	}

	/**
	 * 验证码登录
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/verification/login")
	public BasicResult verificationLogin(@RequestBody @Validated(value = {}) TbRiderParam param) {
		TbRiderResult result = riderService.verificationLogin(param);
		return BasicResult.success(result);
	}

	/**
	 * 微信登录
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/weChat/login")
	public BasicResult wxLogin(@RequestBody @Validated(value = {}) TbRiderParam param) {
		TbRiderResult result = riderService.wxLogin(param);
		return BasicResult.success(result);
	}

	/**
	 * 获取登录用户信息
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/getLoginUserInfo")
	public BasicResult getLoginTbRiderInfo(@RequestBody @Validated(value = {}) TbRiderParam param) {
		TbRiderResult result = riderService.getLoginUserInfo(param);
		return BasicResult.success(result);
	}

	/**
	 * 解除账号绑定的微信
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/removeBindingWx")
	public BasicResult removeBindingWx(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.removeBindingWx(param);
		return BasicResult.success();
	}

	/**
	 * 上传头像
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/uploadHeadImg")
	public BasicResult uploadHeadImg(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.uploadHeadImg(param);
		return BasicResult.success();
	}

	/**
	 * 修改登录密码
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/updatePassword")
	public BasicResult updatePassword(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.updatePassword(param);
		return BasicResult.success();
	}

	/**
	 * 登出
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/logout")
	public BasicResult logout(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.logout(param);
		return BasicResult.success();
	}

	/**
	 * 修改个人资料(邮箱地址、性别、真实姓名)
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/update")
	public BasicResult update(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.update(param);
		return BasicResult.success();
	}

	/**
	 * 上报使用/进入小程序的定位地址
	 *
	 * @author 高品
	 */
	@PostMapping(value = "/updateLastUseAddress")
	public BasicResult updateLastUseAddress(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.updateLastUseAddress(param);
		return BasicResult.success();
	}

	/**
	 * 设置/找回支付密码第一步
	 *
	 * @author 高品
	 */
	@RequestMapping(value = "/forgetPaymentPassword/step1",method = RequestMethod.POST)
	public BasicResult forgetPaymentPasswordStep1(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.forgetPaymentPasswordStep1(param);
		return BasicResult.success();
	}

	/**
	 * 设置/找回支付密码第二步
	 *
	 * @author 高品
	 */
	@RequestMapping(value =  "/forgetPaymentPassword/step2",method = RequestMethod.POST)
	public BasicResult forgetPaymentPasswordStep2(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.forgetPaymentPasswordStep2(param);
		return BasicResult.success();
	}

	/**
	 * 验证支付密码是否正确(场景：支付、提现)
	 *
	 * @author 高品
	 */
	@RequestMapping(value =  "/verifyPaymentPassword",method = RequestMethod.POST)
	@ApiOperation(value = "")
	public BasicResult verifyPaymentPassword(@RequestBody @Validated(value = {}) TbRiderParam param) {
		riderService.verifyPaymentPassword(param);
		return BasicResult.success();
	}

	@ApiOperation(value = "余额提现接口")
	@PostMapping(value = "/withdrawal")
	public BasicResult withdrawal(@RequestBody @Validated(value = {}) RiderWithdrawParam param) {
		riderService.withdrawal(param);
		return BasicResult.success();
	}
}